<template>
  <a-modal title="选用户代报名" :visible="visible" okText="下一步" @ok="handleOk" @cancel="handleCancel">
    <a-form-model layout="horizontal" :labelCol="{ span: 4 }" :wrapperCol="{ span: 20 }">
      <a-form-item label="报名类型">
        <a-select v-model="activityTicketId" placeholder="请选择要赠送的报名类型" allowClear>
          <a-select-option v-for="item in ticketList" :key="item.value" :value="item.id">{{
            item.ticketName
          }}</a-select-option>
        </a-select>
      </a-form-item>
    </a-form-model>
  </a-modal>
</template>

<script>
import { getTicketList } from '@/api/activity/activity'
export default {
  data() {
    return {
      visible: false,
      ticketList: [],
      activityId: undefined,
      activityTicketId: undefined
    }
  },
  methods: {
    handelTicketListDownList() {
      return getTicketList(this.activityId).then(res => {
        if (res.code === 0) {
          this.ticketList = res.data || []
          this.activityTicketId = res.data[0].id
        }
      })
    },
    moduleShow(activityId, title) {
      this.activityId = activityId
      this.handelTicketListDownList()
      this.visible = true
    },
    handleOk() {
      this.visible = false
      this.$emit('ok', this.activityTicketId)
      this.activityTicketId = undefined
    },
    handleCancel() {
      this.activityTicketId = undefined
      this.visible = false
    }
  }
}
</script>
